package com.rran.study.designpattern.behavioral.observer.listener.simple;

import com.rran.study.designpattern.behavioral.observer.event.PlaceOrderEvent;
import com.rran.study.designpattern.behavioral.observer.model.OrderData;
import com.rran.study.designpattern.behavioral.observer.service.PlaceOrderObserver;

/**
 * @author yy
 * @Type GenerateOrdersObserver.java
 * @Desc 订单观察者类
 * @date 2020/7/21 17:34
 */
public class GenerateOrdersObserver implements PlaceOrderObserver {

    @Override
    public void actionPlaceOrder(PlaceOrderEvent e) {
        this.addOrder(e.getOrderData());
    }

    /**
     * 生成订单
     */
    private void addOrder(OrderData orderData) {
        System.out.println("生成订单成功");
        System.out.println("订单金额：" + orderData.getMoney());
        System.out.println("购买商品数：" + orderData.getBuyCount());
    }

}
